<script type="text/javascript">
function validate()
{
    title = document.getElementById("feed_title");
    if (!title.value)
    {
        alert("You must specify a Title for the collection.");
        return false;
    }
    short_title = document.getElementById("feed_short_title");
    if (!short_title.value)
    {
        alert("You must specify a Short Title for the collection.");
        return false;
    }
    h_title = document.getElementById("feed_harvested_from_title");
    if (!h_title.value)
    {
        alert("You must specify a Repository Title.");
        return false;
    }
    h_short_title = document.getElementById("feed_harvested_from_short_title");
    if (!h_short_title.value)
    {
        alert("You must specify a Repository Short Title.");
        return false;
    }
    rss_uri = document.getElementById("feed_uri");
    if (!rss_uri.value)
    {
        alert("You must specify the Address of the Collection Metadata.");
        return false;
    }
    if (rss_uri.value.indexOf("http://") != 0)
    {
        rss_uri.value = "http://" + rss_uri.value;
    }
    display_uri = document.getElementById("feed_display_uri");
    if (display_uri.value && display_uri.value.indexOf("http://") != 0)
    {
        display_uri.value = "http://" + display_uri.value;
    }
    return true;
}
</script>

<h1>Edit Collection Metadata: <%= @feed.title %></h1>

<%= error_messages_for :feed %>

<% form_for :feed, @feed, :url => feed_path(@feed), :html => {:method => :put, :onsubmit => "return validate()"} do |f| %>

  <p>
    <b>Collection Title</b><br />
    <%= f.text_field :title, :size => 100  %>
  </p>

  <p>
    <b>Collection Short Title (this will be appended to resource titles)</b><br />
    <%= f.text_field :short_title, {:maxlength => 30, :size => 30} %>
  </p>

  <p>
    <b>Repository Title</b><br />
    <%= f.text_field :harvested_from_title, :size => 100  %>
  </p>

  <p>
    <b>Repository Short Title</b><br />
    <%= f.text_field :harvested_from_short_title, {:maxlength => 30, :size => 30} %>
  </p>

  <p>
    <b>Address of the Collection Metadata</b><br />
    <%= f.text_field :uri, :size => 100 %>
  </p>

  <p>
    <b>Address of the Collection Home Page</b><br />
    <%= f.text_field :display_uri, :size => 100 %>
  </p>

  <p>
  	<b>Type of Metadata:</b> 
	<select name="feed[service_id]">
		<option value="0">RSS</option>
		<option value="13"<%= @feed.service_id == 13 ? " selected" : ""%>>OAI</option>
	</select>
	<br/>If you specify OAI, you must specify the full url to the ListRecords request (not just the OAI endpoint)
  </p>
  
  <p>
    <b>Description</b><br />
    <%= f.text_field :description, :size => 100  %>
  </p>

  <p>
    <b>How Often to Harvest the Collection</b><br />
    <%= select :feed, "refresh_interval_hours", [["Once a day", "24"], ["Once a week", "168"], ["Once a month", "672"]] %>
  </p>

  <p>
    <%= submit_tag "Update Feed" %>
  </p>

<% end %>

